#pragma once

#include "MeshResource.h"
#include "ResourceMgr.h"
#include "../MemoryManager/Singleton.h"
#include "VertexBuffer.h"
#include "IndexBuffer.h"

#define MAX_VERT_COUNT 5000000 // max of 2mln vertices for a scene

class MeshMgr: 
	public Singleton<MeshMgr>, public ResourceMgr
{
	bufferId_t m_VertexBufferStack;
	bufferId_t m_IndexBufferStack;

public:
	MeshMgr(unsigned numberOfResources): ResourceMgr(numberOfResources, MESH_BUFFER_ID) {
		MemoryMgr& memoryManager = MemoryMgr::getInstance();
		//m_VertexBufferStack = memoryManager.createStackBuffer(VertexBuffer::getBufferSizeFor(1), MAX_VERT_COUNT);
		//m_IndexBufferStack = memoryManager.createStackBuffer(IndexBuffer::getBufferSizeFor(1), MAX_VERT_COUNT);
	}
	~MeshMgr() {}

	// transforms identifier into file path based on resource type
	// and loads the resource
	// clears rarely used resources if needed
	virtual RHANDLE Load(std::wstring identifier);
	//void Unload() { ResourceMgr::Unload<MeshResourceImpl>(); }

	bufferId_t getVertexBufferStack() {
		return m_VertexBufferStack;
	}

	bufferId_t getIndexBufferStack() {
		return m_IndexBufferStack;
	}
};


